<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"><title>Linux常用命令 | Celts</title><meta name="author" content="PaulGeorge"><meta name="copyright" content="PaulGeorge"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="导语 因为在日常工作中会遇到远程控制、部署程序的问题，总会使用到 linux 的相关命令，所以在此总结一些常用的 linux 命令。">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux常用命令">
<meta property="og:url" content="https://curry3035.gitee.io/posts/48230/index.html">
<meta property="og:site_name" content="Celts">
<meta property="og:description" content="导语 因为在日常工作中会遇到远程控制、部署程序的问题，总会使用到 linux 的相关命令，所以在此总结一些常用的 linux 命令。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://curry3035.gitee.io/img/avatar.jpg">
<meta property="article:published_time" content="2021-05-20T14:29:58.000Z">
<meta property="article:modified_time" content="2022-05-26T18:17:11.285Z">
<meta property="article:author" content="PaulGeorge">
<meta property="article:tag" content="linux">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://curry3035.gitee.io/img/avatar.jpg"><link rel="shortcut icon" href="/img/ic.ico"><link rel="canonical" href="https://curry3035.gitee.io/posts/48230/index.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":false,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: PaulGeorge","link":"链接: ","source":"来源: Celts","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"top-right"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  }
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Linux常用命令',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-05-27 02:17:11'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
    win.getCSS = (url,id = false) => new Promise((resolve, reject) => {
      const link = document.createElement('link')
      link.rel = 'stylesheet'
      link.href = url
      if (id) link.id = id
      link.onerror = reject
      link.onload = link.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        link.onload = link.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(link)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/background.css"><link rel="stylesheet" href="/css/my.css"><meta name="generator" content="Hexo 5.4.2"></head><body><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">97</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">64</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">25</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/photos/"><i class="fa-fw fa fa-camera-retro"></i><span> 图库</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gcore.jsdelivr.net/gh/PaulGeorge123/cloudimg@img/mig2023/background05.jpg')"><nav id="nav"><span id="blog-info"><a href="/" title="Celts"><span class="site-name">Celts</span></a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search" href="javascript:void(0);"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fa fa-archive"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fa fa-folder-open"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/photos/"><i class="fa-fw fa fa-camera-retro"></i><span> 图库</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page" href="javascript:void(0);"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Linux常用命令</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-05-20T14:29:58.000Z" title="发表于 2021-05-20 22:29:58">2021-05-20</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-05-26T18:17:11.285Z" title="更新于 2022-05-27 02:17:11">2022-05-27</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Linux/">Linux</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">938</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>3分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Linux常用命令"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h4 id="导语"><a href="#导语" class="headerlink" title="导语"></a>导语</h4><blockquote>
<p>因为在日常工作中会遇到远程控制、部署程序的问题，总会使用到 linux 的相关命令，所以在此总结一些常用的 linux 命令。</p>
</blockquote>
<img src="https://gcore.jsdelivr.net/gh/PaulGeorge123/cloudimg@master/img/all/linux_logo1.png" style="zoom:67%;" />



<span id="more"></span>

<h4 id="Linux-的系统目录结构"><a href="#Linux-的系统目录结构" class="headerlink" title="Linux 的系统目录结构"></a>Linux 的系统目录结构</h4><p><strong>如下图</strong></p>
<img src="https://gcore.jsdelivr.net/gh/PaulGeorge123/cloudimg@master/img/all/d0c50-linux2bfile2bsystem2bhierarchy.jpg" style="zoom: 50%;" />



<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/bin        <span class="comment">## 二进制文件，系统常规命令</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/boot       <span class="comment">## 系统启动分区，系统启动时读取的文件</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/dev        <span class="comment">## 设备文件</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/etc        <span class="comment">## 大多数配置文件</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/home       <span class="comment">## 普通用户的家目录</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/lib        <span class="comment">## 32位函数库</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/lib64      <span class="comment">## 64位库</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/media      <span class="comment">## 手动临时挂载点</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/mnt        <span class="comment">## 手动临时挂载点</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/opt        <span class="comment">## 第三方软件安装位置</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/proc       <span class="comment">## 进程信息及硬件信息</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/root       <span class="comment">## 临时设备的默认挂载点</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/sbin       <span class="comment">## 系统管理命令</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/srv        <span class="comment">## 数据</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/var        <span class="comment">## 数据</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/sys        <span class="comment">## 内核相关信息</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/tmp        <span class="comment">## 临时文件</span></span></span><br><span class="line"><span class="meta prompt_">$ </span><span class="language-bash">/usr        <span class="comment">## 用户相关设定</span></span></span><br></pre></td></tr></table></figure>



<hr>
<h4 id="命令的组成"><a href="#命令的组成" class="headerlink" title="命令的组成"></a>命令的组成</h4><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">$ 示例：命令 参数名 参数值</span><br></pre></td></tr></table></figure>

<h4 id="常用命令"><a href="#常用命令" class="headerlink" title="常用命令"></a>常用命令</h4><h5 id="ls"><a href="#ls" class="headerlink" title="ls"></a>ls</h5><p>【作用】：列出目录内容</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# ls</span><br><span class="line">[root@localhost ~]# ll</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="tree"><a href="#tree" class="headerlink" title="tree"></a>tree</h5><p>【作用】：显示树形目录</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# tree</span><br></pre></td></tr></table></figure>

<blockquote>
<p>需要 yum install -y tree 安装</p>
</blockquote>
<hr>
<h5 id="cd"><a href="#cd" class="headerlink" title="cd"></a>cd</h5><p>【作用】：更改当前目录</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# cd ..</span><br><span class="line">[root@localhost ~]# cd /</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="mkdir"><a href="#mkdir" class="headerlink" title="mkdir"></a>mkdir</h5><p>【作用】：在当前目录下创建下一级目录</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# mkdir test</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="rmdir"><a href="#rmdir" class="headerlink" title="rmdir"></a>rmdir</h5><p>【作用】：仅可以删除空白目录（不可以删除包含内容的目录）</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# rmdir test</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="touch"><a href="#touch" class="headerlink" title="touch"></a>touch</h5><p>【作用】：创建空白文件</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# touch test.txt</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="rm"><a href="#rm" class="headerlink" title="rm"></a>rm</h5><p>【作用】：删除文件</p>
<ul>
<li>删除文件<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# rm [文件名]（删除时会询问是否删除）</span><br><span class="line">[root@localhost ~]# rm -f [文件名]（强制删除）</span><br><span class="line">[root@localhost ~]# rm -v [文件名]（可视化删除）</span><br></pre></td></tr></table></figure></li>
</ul>
<ul>
<li>删除目录<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# rm -r [文件名]（删除时会询问是否删除）</span><br><span class="line">[root@localhost ~]# rm -rf [文件名]（强制删除，若目录不存在，此命令依旧可以执行，不报错）</span><br><span class="line">[root@localhost ~]# rm -rv [文件名]（可视化强制）</span><br></pre></td></tr></table></figure></li>
</ul>
<blockquote>
<p>删除目录和文件时，先删除文件在删除目录</p>
</blockquote>
<hr>
<h5 id="cp"><a href="#cp" class="headerlink" title="cp"></a>cp</h5><p>【作用】：源文件始终不变，仅仅是对目标文件进行改变</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# cp [源文件] [目标文件]</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="mv"><a href="#mv" class="headerlink" title="mv"></a>mv</h5><p>【作用】：mv命令使源文件的状态发生改变</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# mv [源文件] [目标文件]</span><br></pre></td></tr></table></figure>

<blockquote>
<p>若果目录存在，则会将原目录移动到目标目录下；如果目录不存在，则相当于移动并重命名</p>
</blockquote>
<hr>
<h5 id="cat"><a href="#cat" class="headerlink" title="cat"></a>cat</h5><p>【作用】：正序查看文件内容</p>
<ul>
<li>参数-A 查看所有内容，$代表每行的结尾</li>
<li>参数-n 显示行号</li>
</ul>
<p><strong>全文搜索</strong></p>
<p>从前往后搜索：可以输入 <code>/</code>（其中代表要搜索的内容），搜索到的内容会高亮度显示</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# cat -An /etc/passwd</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="tail"><a href="#tail" class="headerlink" title="tail"></a>tail</h5><p>【作用】：用于查看文件的内容，有一个常用的参数 <strong>-f</strong> 常用于查阅正在改变的日志文件</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# tail [参数] [文件]  </span><br></pre></td></tr></table></figure>

<hr>
<h5 id="chmod"><a href="#chmod" class="headerlink" title="chmod"></a>chmod</h5><p>【作用】：更改当前目录权限</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# chmod 777 [文件]</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="tar"><a href="#tar" class="headerlink" title="tar"></a>tar</h5><p>【作用】：打包与解压</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# tar -zcvf 打包压缩后的文件名 要打包的文件</span><br><span class="line">[root@localhost ~]# tar -zxvf a.tar       //解包至当前目录</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="ifconfig"><a href="#ifconfig" class="headerlink" title="ifconfig"></a>ifconfig</h5><p>【作用】：查看网络地址</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# ifconfig</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="ps"><a href="#ps" class="headerlink" title="ps"></a>ps</h5><p>【作用】：查看进程</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# ps -ef         //查看所有正在运行的进程</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="kill"><a href="#kill" class="headerlink" title="kill"></a>kill</h5><p>【作用】：结束进程</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# kill pid       //杀死该pid的进程 </span><br><span class="line">[root@localhost ~]# kill -9 pid    //强制杀死该进程</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="ping"><a href="#ping" class="headerlink" title="ping"></a>ping</h5><p>【作用】：查看与此IP地址的连接情况</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# ping www.baidu.com</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="clear"><a href="#clear" class="headerlink" title="clear"></a>clear</h5><p>【作用】：快速清屏</p>
<figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# clear</span><br></pre></td></tr></table></figure>

<hr>
<h5 id="firewalld"><a href="#firewalld" class="headerlink" title="firewalld"></a>firewalld</h5><h6 id="查看防火墙状态"><a href="#查看防火墙状态" class="headerlink" title="查看防火墙状态"></a>查看防火墙状态</h6><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# systemctl status firewalld</span><br></pre></td></tr></table></figure>

<h6 id="开启防火墙"><a href="#开启防火墙" class="headerlink" title="开启防火墙"></a>开启防火墙</h6><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# systemctl start firewalld</span><br></pre></td></tr></table></figure>

<h6 id="关闭防火墙"><a href="#关闭防火墙" class="headerlink" title="关闭防火墙"></a>关闭防火墙</h6><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# systemctl stop firewalld</span><br></pre></td></tr></table></figure>

<h6 id="设置对外开放访问的端口"><a href="#设置对外开放访问的端口" class="headerlink" title="设置对外开放访问的端口"></a>设置对外开放访问的端口</h6><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# firewall-cmd --add-service=http –permanent </span><br><span class="line">[root@localhost ~]# firewall-cmd --add-port=80/tcp --permanent </span><br></pre></td></tr></table></figure>

<h6 id="重新载入"><a href="#重新载入" class="headerlink" title="重新载入"></a>重新载入</h6><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# firewall-cmd –reload</span><br></pre></td></tr></table></figure>

<h6 id="删除"><a href="#删除" class="headerlink" title="删除"></a>删除</h6><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# firewall-cmd --zone=public --remove-port=80/tcp --permanent</span><br></pre></td></tr></table></figure>

<h6 id="查看已开放的端口号"><a href="#查看已开放的端口号" class="headerlink" title="查看已开放的端口号"></a>查看已开放的端口号</h6><figure class="highlight shell"><table><tr><td class="code"><pre><span class="line">[root@localhost ~]# firewall-cmd --list-all </span><br></pre></td></tr></table></figure>

<hr>
<h5 id="vim-编译"><a href="#vim-编译" class="headerlink" title="vim 编译"></a>vim 编译</h5><figure class="highlight bash"><table><tr><td class="code"><pre><span class="line">:<span class="built_in">set</span> number    --vim显示行号 （一次性）</span><br></pre></td></tr></table></figure>

</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://curry3035.gitee.io">PaulGeorge</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://curry3035.gitee.io/posts/48230/">https://curry3035.gitee.io/posts/48230/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://curry3035.gitee.io" target="_blank">Celts</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/linux/">linux</a></div><div class="post_share"><div class="social-share" data-image="/img/avatar.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/46617/" title="MongoDB概念"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">MongoDB概念</div></div></a></div><div class="next-post pull-right"><a href="/posts/23168/" title="设计模式--总结"><div class="cover" style="background: var(--default-bg-color)"></div><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">设计模式--总结</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">PaulGeorge</div><div class="author-info__description">很多事情就像是旅行一样，当你决定要出发的时候，最困难的那部分其实就已经完成了</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">97</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">64</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">25</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/PaulGeorge123"><i class="fab fa-github"></i><span>GitHub URL</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/PaulGeorge123" target="_blank" title="Github"><i class="fab fa-github"></i></a></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content is-expand"><ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%AF%BC%E8%AF%AD"><span class="toc-number">1.</span> <span class="toc-text">导语</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Linux-%E7%9A%84%E7%B3%BB%E7%BB%9F%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84"><span class="toc-number">2.</span> <span class="toc-text">Linux 的系统目录结构</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%91%BD%E4%BB%A4%E7%9A%84%E7%BB%84%E6%88%90"><span class="toc-number">3.</span> <span class="toc-text">命令的组成</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4"><span class="toc-number">4.</span> <span class="toc-text">常用命令</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#ls"><span class="toc-number">4.1.</span> <span class="toc-text">ls</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#tree"><span class="toc-number">4.2.</span> <span class="toc-text">tree</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#cd"><span class="toc-number">4.3.</span> <span class="toc-text">cd</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#mkdir"><span class="toc-number">4.4.</span> <span class="toc-text">mkdir</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#rmdir"><span class="toc-number">4.5.</span> <span class="toc-text">rmdir</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#touch"><span class="toc-number">4.6.</span> <span class="toc-text">touch</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#rm"><span class="toc-number">4.7.</span> <span class="toc-text">rm</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#cp"><span class="toc-number">4.8.</span> <span class="toc-text">cp</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#mv"><span class="toc-number">4.9.</span> <span class="toc-text">mv</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#cat"><span class="toc-number">4.10.</span> <span class="toc-text">cat</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#tail"><span class="toc-number">4.11.</span> <span class="toc-text">tail</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#chmod"><span class="toc-number">4.12.</span> <span class="toc-text">chmod</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#tar"><span class="toc-number">4.13.</span> <span class="toc-text">tar</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#ifconfig"><span class="toc-number">4.14.</span> <span class="toc-text">ifconfig</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#ps"><span class="toc-number">4.15.</span> <span class="toc-text">ps</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#kill"><span class="toc-number">4.16.</span> <span class="toc-text">kill</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#ping"><span class="toc-number">4.17.</span> <span class="toc-text">ping</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#clear"><span class="toc-number">4.18.</span> <span class="toc-text">clear</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#firewalld"><span class="toc-number">4.19.</span> <span class="toc-text">firewalld</span></a><ol class="toc-child"><li class="toc-item toc-level-6"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E9%98%B2%E7%81%AB%E5%A2%99%E7%8A%B6%E6%80%81"><span class="toc-number">4.19.1.</span> <span class="toc-text">查看防火墙状态</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#%E5%BC%80%E5%90%AF%E9%98%B2%E7%81%AB%E5%A2%99"><span class="toc-number">4.19.2.</span> <span class="toc-text">开启防火墙</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#%E5%85%B3%E9%97%AD%E9%98%B2%E7%81%AB%E5%A2%99"><span class="toc-number">4.19.3.</span> <span class="toc-text">关闭防火墙</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#%E8%AE%BE%E7%BD%AE%E5%AF%B9%E5%A4%96%E5%BC%80%E6%94%BE%E8%AE%BF%E9%97%AE%E7%9A%84%E7%AB%AF%E5%8F%A3"><span class="toc-number">4.19.4.</span> <span class="toc-text">设置对外开放访问的端口</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#%E9%87%8D%E6%96%B0%E8%BD%BD%E5%85%A5"><span class="toc-number">4.19.5.</span> <span class="toc-text">重新载入</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#%E5%88%A0%E9%99%A4"><span class="toc-number">4.19.6.</span> <span class="toc-text">删除</span></a></li><li class="toc-item toc-level-6"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E5%B7%B2%E5%BC%80%E6%94%BE%E7%9A%84%E7%AB%AF%E5%8F%A3%E5%8F%B7"><span class="toc-number">4.19.7.</span> <span class="toc-text">查看已开放的端口号</span></a></li></ol></li><li class="toc-item toc-level-5"><a class="toc-link" href="#vim-%E7%BC%96%E8%AF%91"><span class="toc-number">4.20.</span> <span class="toc-text">vim 编译</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/47231/" title="POI读取Excel问题">POI读取Excel问题</a><time datetime="2023-04-11T01:00:00.000Z" title="发表于 2023-04-11 09:00:00">2023-04-11</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/8422/" title="Excel大文件的上传">Excel大文件的上传</a><time datetime="2023-04-10T01:00:00.000Z" title="发表于 2023-04-10 09:00:00">2023-04-10</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/55119/" title="每日一面--Files工具类">每日一面--Files工具类</a><time datetime="2023-01-01T01:00:00.000Z" title="发表于 2023-01-01 09:00:00">2023-01-01</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/34600/" title="面试一下--JUC入门">面试一下--JUC入门</a><time datetime="2022-09-10T01:00:00.000Z" title="发表于 2022-09-10 09:00:00">2022-09-10</time></div></div><div class="aside-list-item no-cover"><div class="content"><a class="title" href="/posts/16284/" title="每日一面--字符流和字节流">每日一面--字符流和字节流</a><time datetime="2022-07-01T01:00:00.000Z" title="发表于 2022-07-01 09:00:00">2022-07-01</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://gcore.jsdelivr.net/gh/PaulGeorge123/cloudimg@img/mig2023/background05.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By PaulGeorge</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></body></html>